home *** CD-ROM | disk | FTP | other *** search
- Path: news.sinet.slb.com!usenet
- From: "Vinh D. Nguyen" <vnguyen@sugar-land.anadrill.slb.com>
- Newsgroups: comp.lang.c++
- Subject: Re: Calling DLL-Functions?
- Date: Tue, 12 Mar 1996 08:08:58 -0600
- Organization: Schlumberger Anadrill
- Message-ID: <3145857A.5BD2@sugar-land.anadrill.slb.com>
- References: <4hhsr6$vm5@taco.cc.ncsu.edu> <4hktpc$1h2@vega.info.isbiel.ch>
- NNTP-Posting-Host: 163.185.118.40
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (WinNT; I)
-
- Juestrich Marc wrote:
- >
- > I'm just a beginner in programming C/C++, so it's maybe easy to anser this
- > basic question:
- >
- > How can I call a Function in a DLL. I've got the description of this DLL and I
- > also was reading something about LoadLibrary or GetProcAdd etc.
- >
- > Is this the right way to go? Could you please give me an example?
- > What are the advanteges of Link-or Runtime linking?
- >
- > Please mail me Marc
- >
- > (excuse my bad english)
-
- To call a function in a DLL, you can use one of two approaches:
-
- 1. Use LoadLibrary to load the DLL at runtime and then use GetProcAddress
- to retrieve the address of the fucntion you want to call. This approach is
- more dynamic since you can check for the existence of the DLL and the function
- before invoking it. You can also call the same function in alternative DLLs
- depending on their existence or some other critera.
-
- 2. When you build a DLL, you can also generate something called the import libary
- ( with the .lib) extension. This import library acts like a static library in
- the sense that you link it into your application at compile (actually link) time.
- The import library simply contains a table of offsets for the functions in the
- DLL so that you can call the function directly as if the function is contained in
- a static library. The drawback of this approach is the existence of the library is
- checked when the application is launched. If the DLL does not exist, your application
- will shutdown. In other words, it's an all-or-nothing deal.
-
- Hope this helps.
-
- --
- --------------------------------------------------------------------------
- * Vinh Nguyen vnguyen@slb.com *
- * Drilling Information Products - Senior Engineer *
- * Anadrill Schlumberger *
- * 200 Gillingham Ln. (713) 275-7524 (Office) *
- * Sugarland, TX 77478 (713) 275-8098 (FAX) *
- --------------------------------------------------------------------------
-